package org.csu.logistics.Service;

import org.csu.logistics.common.CommonResponse;
import org.csu.logistics.entity.UnitPrice;
import org.csu.logistics.persistence.UnitPriceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("UnitPriceService")
public class UnitPriceServiceImp implements UnitPriceService{

    @Autowired
    UnitPriceMapper unitPriceMapper;

    @Override
    public void insert_unitPrice(UnitPrice unitPrice) {
        unitPriceMapper.insert(unitPrice);
    }

    @Override
    public void delete_unitPriceByTransportMode(String transportMode) {
        unitPriceMapper.deleteById(transportMode);
    }

    @Override
    public void update_unitPriceByTransportMode(UnitPrice unitPrice) {
        unitPriceMapper.updateById(unitPrice);
    }

    @Override
    public CommonResponse<UnitPrice> select_UnitPriceByTransPortMode(String transPortMode) {

        UnitPrice unitPrice = unitPriceMapper.selectById(transPortMode);
        if(unitPrice==null){
            return CommonResponse.createForError("没有这个运输方式");
        }
        return CommonResponse.createForSuccess(unitPrice);
    }
}
